package GUI;
/**
 * in the process of the teacher substitution the administration selects from which class 
 * the teacher wants to be dismissed
 */

import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JComboBox;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.util.Vector;

public class SubTeacherSelCls extends JPanel {
	private JLabel label = null;
	private JLabel label_1 = null;
	private JComboBox cBSelClass = null;
	private JButton btnNext = null;
	
	public Login myLoginFrame = null;
	public UserAdmin user=null;
	public AdminMainMenu amn=null;	
	private TeacherAllocationToClass teacherAllocScrn_4=null;
	private String selClass = null;
	
	
	public JComboBox getcBSelClass(AdminMainMenu amn)
	{
		Vector<String> data = new Vector<String>();
		int i;
		for(i=0;i<amn.user.DataForEx.CoursesOfClasses.size();i++)
		{
			if(amn.user.DataForEx.getSelCourse().endsWith(amn.user.DataForEx.CoursesOfClasses.get(i).Cid)&&
					(amn.user.DataForEx.getSelSubsTeacher().endsWith(amn.user.DataForEx.CoursesOfClasses.get(i).TeacherID)))
				
				{
			    data.add(amn.user.DataForEx.CoursesOfClasses.get(i).ClassID);
				}
		}
		if(cBSelClass==null)
		{
			cBSelClass = new JComboBox(data);
			cBSelClass.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					selClass=cBSelClass.getSelectedItem().toString();
			 		System.out.println(selClass);
					
					
				}
			});
			cBSelClass.setBounds(256, 77, 178, 20);
		}
		return cBSelClass;
	}
	
	
	public JButton getBtnNext(final AdminMainMenu amn)
	{
		if(btnNext==null)
		{
		btnNext = new JButton("Next");
		btnNext.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				teacherAllocScrn_4 = null;
				amn.user.DataForEx.setSelClass(selClass);
				teacherAllocScrn_4 = amn.getTeacherAllocScrn_4();
				amn.setContentPane(teacherAllocScrn_4);
			}
		});
		btnNext.setBounds(517, 315, 89, 23);
		}
		
		return  btnNext ;
		
	}
	
	public void initialize(AdminMainMenu amn)
	{
		setLayout(null);
		
		 label = new JLabel("Exceptional request - Teacher allocation from class");
		label.setBounds(242, 11, 243, 14);
		add(label);
		
		label_1 = new JLabel("Select class:");
		label_1.setBounds(64, 80, 138, 14);
		add(label_1);
		add(getcBSelClass(amn));
		add(getBtnNext(amn));
		
	}
	
	
	
	
	
	public SubTeacherSelCls(AdminMainMenu amn) {
		super();
		initialize(amn);
		
	}
}


